package test2;

import test2.Operation.*;

import java.io.IOException;
import java.util.TreeMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-04-22
 * Time: 21:12
 */
public class Student implements Comparable<Student>{
    private String id;
    private String name;
    private String tele;
    private String email;
    private int age;
    public IOperation[] iOperations;
    public Student() {
        this.iOperations=new IOperation[]{
                new ExitOperation(),
                new AddOperation(),
                new InputFileOperation(),
                new OutFileOperation()
        };
    }
    public void doOperation(int choice, TreeMap<String,Student> treeMap) throws IOException {

        iOperations[choice].work(treeMap);
    }
    public Student(String id, String name, String tele, String email,int age) {
        this.id = id;
        this.name = name;
        this.tele = tele;
        this.email = email;
        this.age=age;
        this.iOperations=new IOperation[]{
                new ExitOperation(),
                new AddOperation(),
                new InputFileOperation(),
                new OutFileOperation()
        };
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", tele='" + tele + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                '}';
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTele() {
        return tele;
    }

    public void setTele(String tele) {
        this.tele = tele;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public int compareTo(Student o) {
        return this.id.compareTo(o.getId());
    }
}
